package com.dream.technology.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.junit.Test;
import org.springframework.util.StopWatch;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @author chen_q_i@163.com
 * @version 1.0
 * @date 2020/12/30 11:08 上午
 */
public class EasyexcelT {


    @Test
    public void uploadFtp(){

        EasyExcel.write(fileName, DemoData.class).sheet("模板").doWrite(data());



    }

    @Test
    public void TExport() throws IllegalAccessException, IOException {
        StopWatch export = new StopWatch("export");
        export.start("buildData");
        ArrayList<Student> students = new ArrayList<>(200000);
        for (int i = 0; i < 200000; i++) {
            Student student = new Student();
            student.setStuNo(String.valueOf(i));
            student.setName("name"+i);
            student.setAcademy("aa"+i);
            students.add(student);
        }
        export.stop();
        export.start("writter");

        String s = export.prettyPrint();
        System.out.println(s);

    }

    @Data
    class Student {
           @ExcelProperty(value = "学号", index = 0)
        private String stuNo;
        @ExcelProperty(value = "姓名", index = 1)
        private String name;
        @ExcelProperty(value = "学院", index = 3)
        private String academy;


    }
}
